package com.lxl.pojo;

public class BaseIp {
    private long[] ipPoints;
    private long ipRealNum;

    public BaseIp(String ip){
        ipPoints = new long[4];
        String[] ipNumStr = ip.split("\\.");
        for (int i=0;i<ipNumStr.length;i++){
            ipPoints[i] = Long.parseLong(ipNumStr[i]);
        }
        ipRealNum = calculateLong();
    }

    private long calculateLong(){
        long r1 = ipPoints[0] * 256 * 256 * 256;
        long r2 = ipPoints[1] * 256 * 256;
        long r3 = ipPoints[2] * 256;
        long r4 = ipPoints[3];
        return r1 + r2 + r3 + r4;
    }

    public long getLong(){
        return ipRealNum;
    }

}
